﻿@model EnetaMvc.ApplicationServices.Dto.BlogDto
@{
    ViewBag.Title = "Edit";
    Layout = "~/Views/Shared/_NewsLayout.cshtml";

    var title = (Model == null || Model.Id == 0) ? Resources.EnetaMvc.AddBlog : Resources.EnetaMvc.EditBlog;
    ViewBag.Title = title;
    
    var user = Html.GetCurrentUser();
}

<div class="blog-head" style="padding: 0px;"> 
    <div class="blog-head-txt">
        <h2 style="padding-left: 18px">@title</h2>
    </div>
    <div class="tsentraliseeritud">
        <ul class="list">
            <li>Enetaga on oodatud liituma kõik eesti keelsete tehnoloogia-alaste blogide autorid. Portaalis ilmuvad postitused, mis on seotud Microsoftiga või käsitlevad platvormist sõltumatut tehnoloogiamaailma. Uudised, kogemuste jagamine ja konstruktiivne kriitika on alati teretulnud, kuid ebasobiliku sõnavaraga või vaenu õhutavaid kandeid ei avaldata.</li>
        </ul>
    </div>
</div>

<div class="comentaries-area">
    <div class="enter-information">
        <form method="post">
        @if(Model != null)
        {
            @Html.HiddenFor(m => m.Id)
        }
        else 
        {
            @Html.Hidden("Id", 0);
        }
        <fieldset>
            <div class="info-row">
                @Html.ValidationMessageFor(m => m.Name)
                <div class="title">
                    <h5>@Resources.EnetaMvc.BlogName</h5>
                </div>
                <div class="error-note"> <span>*</span> </div>
                <div class="information-main">
                    @Html.TextBoxFor(m => m.Name)
                </div>
            </div>
            <div class="info-row">
                @Html.ValidationMessageFor(m => m.Url)
                <div class="title">
                    <h5>@Resources.EnetaMvc.BlogUrl</h5>
                </div>
                <div class="error-note"> <span>*</span> </div>
                <div class="information-main">
                    @Html.TextBoxFor(m => m.Url)
                </div>
            </div>
            <div class="info-row">
                @Html.ValidationMessageFor(m => m.RssUrl)
                <div class="title">
                    <h5>@Resources.EnetaMvc.BlogRssUrl</h5>
                </div>
                <div class="error-note"> <span>*</span> </div>
                <div class="information-main">
                    @Html.TextBoxFor(m => m.RssUrl)
                </div>
            </div>
            <div class="info-row">
                @Html.ValidationMessageFor(m => m.Description)
                <div class="title">
                    <h5>@Resources.EnetaMvc.BlogDescription</h5>
                </div>
                <div class="error-note"> <span>*</span> </div>
                <div class="information-main">
                    @Html.TextAreaFor(m => m.Description)
                </div>
            </div>
            <div class="info-row">
                @Html.ValidationMessageFor(m => m.FirstPostDate)
                <div class="title">
                    <h5>@Resources.EnetaMvc.BlogFirstPostDate</h5>
                </div>
                <div class="error-note"> <span>*</span> </div>
                <div class="information-main">
                    @Html.TextBoxFor(m => m.FirstPostDate, new { @class = "datepicker" })
                </div>
            </div>
            @if (!User.IsInRole("Administrator"))
            {
                <div class="info-row">
                    <div class="title">
                        <h5>@Resources.EnetaMvc.PublishState</h5>
                    </div>
                    <div class="information-main">
                        @Html.DisplayFor(m => m.PublishingStateName)
                    </div>
                </div>
                <div class="info-row">
                    <div class="title">
                        <h5>@Resources.EnetaMvc.PublishStateBy</h5>
                    </div>
                    <div class="information-main">
                        @Html.DisplayFor(m => m.PublishingStateByUserName)
                    </div>
                </div>
                <div class="info-row">
                    <div class="title">
                        <h5>@Resources.EnetaMvc.PublishStateDate</h5>
                    </div>
                    <div class="information-main">
                        @Html.DisplayFor(m => m.PublishingStateDate)
                    </div>
                </div>
                <div class="info-row">
                    <div class="title">
                        <h5>@Resources.EnetaMvc.PublishComment</h5>
                    </div>
                    <div class="information-main">
                        @Html.DisplayFor(m => m.PublishingStateComment)
                    </div>
                </div>
            }
            else
            { 
                <div class="info-row">
                    <div class="title">
                        <h5>@Resources.EnetaMvc.PublishState</h5>
                    </div>
                    <div class="information-main">
                        @Html.DropDownListFor(m => m.PublishingStateId, Html.GetPublishStatesWithSelection(Model.PublishingStateId))
                    </div>
                </div>
                if(Model.Id != 0)
                {
                    <div class="info-row">
                        <div class="title">
                            <h5>@Resources.EnetaMvc.PublishStateBy</h5>
                        </div>
                        <div class="information-main">
                            @Html.DisplayFor(m => m.PublishingStateByUserName)
                        </div>
                    </div>
                    <div class="info-row">
                        <div class="title">
                            <h5>@Resources.EnetaMvc.PublishStateDate</h5>
                        </div>
                        <div class="information-main">
                            @Html.DisplayFor(m => m.PublishingStateDate)
                        </div>
                    </div>
                }
                <div class="info-row">
                    <div class="title">
                        <h5>@Resources.EnetaMvc.PublishComment</h5>
                    </div>
                    <div class="information-main">
                        @Html.TextBoxFor(m => m.PublishingStateComment)
                    </div>
                </div>
            }

            <div class="submit">
				<input type="submit" value="@Resources.EnetaMvc.Save"/>
			</div>
			<a class="loobu" href="@Url.Content("~/profiles/details/" + Model.Id)">@Resources.EnetaMvc.Cancel</a>
            <p style="display:block;clear: both">&nbsp;</p>
        </fieldset>
        </form>
    </div>
</div>